using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace DaoHang.Models
{
    /// <summary>
    /// 网站实体类，用于存储网站导航信息
    /// </summary>
    public class Website
    {
        /// <summary>
        /// 网站ID，主键
        /// </summary>
        [Key]
        public int Id { get; set; }

        /// <summary>
        /// 网站名称，最大长度200字符，不可为空
        /// </summary>
        [Required(ErrorMessage = "网站名称不能为空")]
        [MaxLength(200, ErrorMessage = "网站名称不能超过200个字符")]
        public string Name { get; set; } = string.Empty;

        /// <summary>
        /// 网站URL地址，最大长度500字符，不可为空
        /// </summary>
        [Required(ErrorMessage = "网站地址不能为空")]
        [MaxLength(500, ErrorMessage = "网站地址不能超过500个字符")]
        [Url(ErrorMessage = "请输入有效的网站地址")]
        public string Url { get; set; } = string.Empty;

        /// <summary>
        /// 网站描述，最大长度1000字符
        /// </summary>
        [MaxLength(1000, ErrorMessage = "网站描述不能超过1000个字符")]
        public string? Description { get; set; }

        /// <summary>
        /// 网站图标URL地址，最大长度500字符
        /// </summary>
        [MaxLength(500, ErrorMessage = "图标地址不能超过500个字符")]
        public string? IconUrl { get; set; }

        /// <summary>
        /// 关键词标签，用逗号分隔
        /// </summary>
        [MaxLength(500, ErrorMessage = "标签不能超过500个字符")]
        public string Tags { get; set; } = string.Empty;

        /// <summary>
        /// 是否推荐网站
        /// </summary>
        public bool IsRecommended { get; set; } = false;

        /// <summary>
        /// 所属分类ID，外键
        /// </summary>
        [Required(ErrorMessage = "必须选择分类")]
        [Range(1, int.MaxValue, ErrorMessage = "必须选择分类")]
        public int CategoryId { get; set; }

        /// <summary>
        /// 排序顺序，数字越小越靠前
        /// </summary>
        public int SortOrder { get; set; } = 0;

        /// <summary>
        /// 访问次数，用于记录网站被访问的频率，用于排序
        /// </summary>
        public int VisitCount { get; set; } = 0;

        /// <summary>
        /// ICP备案号（网站备案号）
        /// </summary>
        [MaxLength(100, ErrorMessage = "ICP备案号不能超过100个字符")]
        public string? IcpNumber { get; set; }

        /// <summary>
        /// 公安备案号
        /// </summary>
        [MaxLength(100, ErrorMessage = "公安备案号不能超过100个字符")]
        public string? PoliceNumber { get; set; }

        /// <summary>
        /// 是否为中国网站（用于显示备案信息）
        /// </summary>
        public bool IsChineseWebsite { get; set; } = false;

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreateTime { get; set; } = DateTime.Now;

        /// <summary>
        /// 所属分类，导航属性
        /// </summary>
        [ForeignKey("CategoryId")]
        public virtual Category Category { get; set; } = null!;
    }
} 